package com.atguigu.gmallsugar.mapper;

import com.atguigu.gmallsugar.bean.Province;
import com.atguigu.gmallsugar.bean.Spu;
import com.atguigu.gmallsugar.bean.Tm;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

public interface TradeMapper {
    @Select("select sum(order_amount) as order_amount from dws_trade_sku_order_window " +
            " where toYYYYMMDD(stt) = #{date}")
    BigDecimal gmv(Integer date);

    @Select("select spu_name,sum(order_amount) order_amount from dws_trade_sku_order_window " +
            " where toYYYYMMDD(stt)=#{date} group by spu_name")
    List<Spu> gmvBySpu(Integer date);

    @Select("select trademark_name , sum(order_amount) as order_amount" +
            " from dws_trade_sku_order_window where toYYYYMMDD(stt) = #{date} group by trademark_name")
    List<Tm> gmvByTm(Integer date);

    @Select("select province_name, sum(order_amount) as order_amount," +
            " sum(order_count) as order_count " +
            " from dws_trade_province_order_window " +
            " where toYYYYMMDD(stt) = #{date} " +
            " group by province_name")
    List<Province> province(Integer date);
}
